#{extends '/template/main.html' /}
<!-- Removing search and results count filter -->
<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">全部会员</h3>
    </div>
    <div class="panel-body">
        <form method="get" id="searchForm" action="/BS0008/admin/webuser/buyIndex/${pageNumber}">
            <div style="margin-bottom: 20px;width:160px;float: left;">
                <input type="text" name="goodsName" id="goodsName" class="form-control" style="width:150px" placeholder="商品名称" value="${goodsName}">
            </div>

                <input type="hidden" name="userId" id="userId"   value="${userId}">

        </form>
        <button class="btn btn-turquoise" id="searchBtn">开始检索</button>
        <span style="margin-left: 20px;">总消费：</span><span>${sumAmount}</span>
        <table class="table table-bordered table-striped" id="example-2">
            <thead>
            <tr>
                <th class="no-sorting">
                    <input type="checkbox" class="cbr">
                </th>
                <th>商品名称</th>
                <th>购买数量</th>
                <th>销售单价</th>
                <th>总金额</th>
                <th>下单时间</th>
            </tr>
            </thead>

            <tbody class="middle-align">

            #{list resultPage,as:'orderItem'}
            <tr>
                <td>
                    <input type="checkbox" class="cbr">
                </td>
                <td>${orderItem?.goods?.name}</td>
                <td>${orderItem?.buyNumber}</td>
                <td>${orderItem?.salePrice}</td>
                <td>${orderItem?.amount}</td>
                <td>${orderItem?.createdAt}</td>
            </tr>
            #{/list}

            </tbody>
        </table>
        <div id="layerPage" class="col-xs-12"></div>
    </div>
</div>



<!-- Imported styles on this page -->
<link rel="stylesheet" href="/public/js/datatables/dataTables.bootstrap.css">

<script src="/public/js/datatables/js/jquery.dataTables.min.js"></script>


<!-- Imported scripts on this page -->
<script src="/public/js/datatables/dataTables.bootstrap.js"></script>
<script src="/public/js/datatables/yadcf/jquery.dataTables.yadcf.js"></script>
<script src="/public/js/datatables/tabletools/dataTables.tableTools.min.js"></script>

<script type="text/javascript" src="/public/laypage/laypage.js"></script>
<script type="text/javascript">
    console.log(${userId})
    $(document).ready(function(){
        // 提示
        var msg = '${flash.get("msg")}';
        if(msg) {
            saveSuccess(msg);
        }

        // 分页
        laypage({
            cont: $('#layerPage'), //容器。值支持id名、原生dom对象，jquery对象,
            pages: '${resultPage.pageCount}', //总页数
            skin: 'yahei',
            skip: true, //是否开启跳页
            curr:'${pageNumber}',
            jump: function(e, first){ //触发分页后的回调
                if(!first){ //一定要加此判断，否则初始时会无限刷新
                    $('#pageNumber').val(e.curr);
                    $("#searchForm").attr("action", "/BS0008/admin/webuser/buyIndex/"+e.curr);
                    $('#searchForm').submit();
                }
            }
        });
        $(document).on("click", "#searchBtn", function(){
            $("#searchForm").attr("action", "/BS0008/admin/webuser/buyIndex/1");
            $('#searchForm').submit();
        })
    });

</script>


